#include <cassert>
#include <xscript/xitemstring.h>
#include <xscript/xscriptexecutor.h>
#include <astree/xabstractsyntaxtreelet.h>
#include <astree/xabstractsyntaxtreevalue.h>
#include <astree/xabstractsyntaxtreebuilderimpl.h>

/*
bool XAbstractSyntaxTreeCreatorLet::isMatched(const XTokenBlock& tokens, uint32_t row, uint32_t col) {
    if (tokens.size() <= row)
        return false;

    auto set = tokens.at(row);
    if (set.tokens.size() <= col)
        return false;

    if (set.tokens.at(col)->getString() == L"let")
        return true;
    return false;
}

std::shared_ptr<XAbstractSyntaxTree> XAbstractSyntaxTreeCreatorLet::create(const XTokenBlock& tokens, uint32_t row, uint32_t col, std::shared_ptr<XAbstractSyntaxTreeBuilder> builder) {
    auto tokenLine = tokens.at(row);
    auto list = tokenLine.tokens;

    assert(list.at(col)->getString() == L"let");
    auto command = list.at(col);

    col ++;
    if (list.size() <= col) {
        XScriptExecutor::getInstance()->setError(XError::XError_NeedMoreTokenError, list.at(col - 1)->toString());
        return nullptr;
    }

    auto var = list.at(col);
    if (!var->asVariable()) {
        XScriptExecutor::getInstance()->setError(XError::XError_BadTokenError, list.at(col)->toString());
        return nullptr;
    }

    col ++;
    if (list.size() <= col) {
        XScriptExecutor::getInstance()->setError(XError::XError_NeedMoreTokenError, list.at(col - 1)->toString());
        return nullptr;
    }

    if (list.at(col)->toString() != L"=") {
        XScriptExecutor::getInstance()->setError(XError::XError_BadTokenError, list.at(col)->toString());
        return nullptr;
    }

    std::shared_ptr<XAbstractSyntaxTreeLet> let = std::make_shared<XAbstractSyntaxTreeLet>(command);
    let->addChild(std::make_shared<XAbstractSyntaxTreeValue>(var, std::make_shared<XItemString>(var->toString())));
    skipToCol = col + 1;
    return let;
}

*/










